package com.hmall.trade.listener;

import com.hmall.trade.service.IOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class PayStatusListener {

    @Autowired
    private IOrderService orderService;
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(value = "pay.status.queue", durable = "true"),
            exchange = @Exchange(value = "pay-exchange-toipc", type = ExchangeTypes.TOPIC),
            key = "pay.success.#"))
    public void handlePayStatus(Long orderId) {
        log.info("订单支付成功，开始处理订单状态");
        orderService.markOrderPaySuccess(orderId);
    }
}
